package org.xue.snowmall.bargain.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import org.xue.snowmall.bargain.entity.BargainEntity;
import org.xue.snowmall.bargain.service.BargainService;
import org.xue.snowmall.common.utils.PageUtils;
import org.xue.snowmall.common.utils.R;



/**
 * 
 *
 * @author zy
 * @email 2067065884@qq.com
 * @date 2021-09-25 19:08:58
 */
@RestController
@RequestMapping("bargain/bargain")
public class BargainController {
    @Autowired
    private BargainService bargainService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bargainService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{gsmBargainId}")
    public R info(@PathVariable("gsmBargainId") Long gsmBargainId){
		BargainEntity bargain = bargainService.getById(gsmBargainId);

        return R.ok().put("bargain", bargain);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BargainEntity bargain){

        return bargainService.saveBargain(bargain);
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BargainEntity bargain){
		bargainService.updateById(bargain);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] gsmBargainIds){
		bargainService.removeByIds(Arrays.asList(gsmBargainIds));

        return R.ok();
    }

}
